package com.selly.hanjuang;


import com.selly.hanjuang.lib.MyApplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton;

public class MenuAwal extends Activity implements OnClickListener {
	//public static int statusKeranjang;

	private Animation animAlpha;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.menu);

		animAlpha = AnimationUtils.loadAnimation(this, R.anim.anim_alpha);

		ImageButton btnPemesanan = (ImageButton) findViewById(R.id.btnpemesanan);
		btnPemesanan.setOnClickListener(this);

		ImageButton btnTentangAplikasi = (ImageButton) findViewById(R.id.btnaplikasi);
		btnTentangAplikasi.setOnClickListener(this);

		haruskanGini();
	}

	private void haruskanGini() {
		// cikan di menu
		// set
		((MyApplication) this.getApplication()).setStringValue("di menu coy");
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnpemesanan:
			v.startAnimation(animAlpha);
			startActivity(new Intent("com.selly.hanjuang.MENUPEMESANAN"));
			break;
		case R.id.btnaplikasi:
			v.startAnimation(animAlpha);
			startActivity(new Intent("com.selly.hanjuang.TENTANGAPLIKASI"));
			break;
		}
	}
	
	/* Initiating Menu XML file (menu.xml) */
    public boolean onCreateOptionsMenu(Menu menu)
    {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.layout.menu_context, menu);
        return true;
    }
    
    /**
     * Event Handling for Individual menu item selected
     * Identify single menu item by it's id
     * */
    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        
        switch (item.getItemId())
        {
        case R.id.menu_view_cart:
        	// Single menu item is selected do something
        	// Ex: launching new activity/screen or show alert message
            //Toast.makeText(MenuAwal.this, "Bookmark is Selected", Toast.LENGTH_SHORT).show();
        	startActivity(new Intent("com.selly.hanjuang.TENTANGAPLIKASI"));
            return true;
            /*
        case R.id.menu_save:
        	Toast.makeText(MenuAwal.this, "Save is Selected", Toast.LENGTH_SHORT).show();
            return true;
        case R.id.menu_search:
        	Toast.makeText(MenuAwal.this, "Search is Selected", Toast.LENGTH_SHORT).show();
            return true;
        case R.id.menu_share:
        	Toast.makeText(MenuAwal.this, "Share is Selected", Toast.LENGTH_SHORT).show();
            return true;
        case R.id.menu_delete:
        	Toast.makeText(MenuAwal.this, "Delete is Selected", Toast.LENGTH_SHORT).show();
            return true;
        case R.id.menu_preferences:
        	Toast.makeText(MenuAwal.this, "Preferences is Selected", Toast.LENGTH_SHORT).show();
            return true;
            */
        default:
            return super.onOptionsItemSelected(item);
        }
    }

}
